<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .test {
            color:#f00;
        }
    </style>
</head>
<body>
    <h2 class="title">React演示</h2>
    <div id="root"></div>
</body>
<script src="./lib/react.js"></script>
<script src="./lib/react-dom.js"></script>
<script>
    //获取dom
    const box=document.querySelector('#root')
    //创建一个react根元素
    const root=ReactDOM.createRoot(box)
    //虚拟dom写法,h函数
    const h=React.createElement;
    //通过h函数创建了一个元素
    const element=h(
            'div',
            {className:'test'},
            h('p',
                {
                    className:'abc',
                    onClick:()=>console.log('我点击了p标签')
                },
                '我是一个段落')
            )

    //渲染元素到浏览器上
    root.render(element)


</script>
</html>